﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NCRGEA.UserControls
{
    public partial class ucDateText : UserControl
    {
        string text = string.Empty;

        public ucDateText()
        {
            InitializeComponent();
        }

        public string getText()
        {
            return text;
        }

        private void txtText_Leave(object sender, EventArgs e)
        {
            //Validate the textbox and makes sure that it is formated in the correct date
            DateTime day = new DateTime();
            if (!(DateTime.TryParse(txtText.Text, out day)) && txtText.Text != string.Empty)
            {
                MessageBox.Show("This was not a correct date format.");
                txtText.Clear();
            }
            else
            {
                if (txtText.Text != string.Empty)
                {
                    DateTime temp;
                    temp = DateTime.Parse(txtText.Text);
                    text = temp.Year + "/" + temp.Month + "/" + temp.Day;
                }
            }
        }
    }
}